package com.dotflat.check.repository;

import com.dotflat.check.domain.Checker;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
public interface CheckerRepository extends JpaRepository<Checker, String>, JpaSpecificationExecutor<Checker> {

    @Query(value="SELECT  ifnull(checkerId,'0') id FROM  c_checker ORDER BY created  limit 1 ",nativeQuery = true)
    Integer getMaxId();

    Checker findAllByCheckerIdAndLoginPass(Integer  checkerId ,Integer loginPass);

    Checker findByCheckerId(Integer checkerId);

    Checker findFirstByDevSnoAndDeletedIsFalse(String devNo);

    @Query("SELECT c FROM Checker c WHERE c.devSno = ?1 AND c.areaId = ?2 AND c.deleted = false")
    Checker findFirstByDevSnoAndAreaIdAndDeletedIsFalse(String devSno, String areaId);
}
